package ModelLayer;
/**
 * The Product class holds information about a product.
 * A product inherits variables from superclass Item.
 * 
 * @author  Mie P., Danny M.P., Jakob K., Anna K., Anders A.P.  
 * @version 1.0
 */
public class Product extends Item {

    private Supplier supplier;
    private int quantityInBulk;
    private double purchasePrice;
    private double salesPriceBulk;
    private double size;
    private double weight;

    /**
     * Constructor for objects of class Product
     * 
     * @param name              Name of the product.
     * @param description       A description of the product.
     * @param supplier          The supplier of the product. The supplier must be created in the system.
     * @param quantityInBulk    The number of products in a package, eg. 10 in one package.
     * @param purchasePrice     The price paid to the supplier for the product.
     * @param size              The size of the product measured in cubic cm.
     * @param weight            The weight of the product.
     */
    public Product(String name, String description, Supplier supplier, int quantityInBulk,
                   double purchasePrice, double size, double weight) {

        super(name, description);
        setSupplier(supplier);
        setQuantityInBulk(quantityInBulk);
        setPurchasePrice(purchasePrice);
        setSize(size);
        setWeight(weight);
        salesPriceBulk = -1;

    }

    /**
     * Set the supplier.
     * 
     * @param input The supplier of the product. The supplier must be created in the system.
     */
    public void setSupplier(Supplier input) {

        supplier = input;

    }

    /**
     * Set the quantityInBulk.
     * 
     * @param input        The number of products in a package, eg. 10 in one package.
     */
    public void setQuantityInBulk(int input) {

        quantityInBulk = input;

    }

    /**
     * Set the purchasePrice.
     * 
     * @param input         The price paid to the supplier for the product.
     */
    public void setPurchasePrice(double input) {

        purchasePrice = input;

    }

    /**
     * Set the size.
     * 
     * @param input The size of the product measured in cubic cm.
     */
    public void setSize(double input) {

        size = input;

    }

    /**
     * Set the weight.
     * 
     * @param input The weight of the product.
     */
    public void setWeight(double input) {

            weight = input;

    }

    /**
     * Set the salesPriceBulk.
     * 
     * @param input         The sales price of a package.
     */
    public void setSalesPriceBulk(double input) {

            salesPriceBulk = input;

    }

    /**
     * Returns the Supplier object associated with the product.
     *
     * @return  supplier  a Supplier object.  
     */    
    public Supplier getSupplier() {

        return this.supplier;

    }

    /**
     * Returns the Product object's quantityunBulk field's value the caller.
     *
     * @return  quantityInBulk  number of products in bulk.  
     */    
    public int getQuantityInBulk() {

        return this.quantityInBulk;

    }

    /**
     * Accessor method for purchasePrice.
     * 
     * @return  purchasePrice   the value of purchasePrice.
     */
    public double getPurchasePrice() {

        return this.purchasePrice;

    }

    /**
     * Accessor method for size.
     * 
     * @return  size     the value of size.
     */
    public double getSize() {
      
        return this.size;
    
    }

    /**
     * Accessor method for weight.
     * 
     * @return  weight  the value of weight.
     */
    public double getWeight() {

        return this.weight;

    }

    /**
     * Accessor method for salesPriceBulk.
     * 
     * @return  salesPriceBulk  The value of salesPriceBulk.
     * @throw   Exception       If the price is not set.
     */
    public double getSalesPriceBulk() throws Exception {

        if (this.salesPriceBulk != -1) {
            return this.salesPriceBulk;
        }
        else {
            throw new IllegalArgumentException("Kolli prisen på produktet er ikke sat");
        }

    }

}